package com.example.store2.Controller;

import com.example.store2.Service.UserService;
import com.example.store2.pojo.Result;
import com.example.store2.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/register")
public class RegisterController {
    @Autowired
    UserService userService;

    @PostMapping
    public Result regiser(@RequestBody User user){
        log.info("注册的用户为:{}",user);
        if(userService.regiser(user))
            return Result.success();
        else
            return Result.error("用户已存在");
    }
}
